<template>
	<view class="navbar" :style="{ height: navBarHeight + 'px', background: background }">

		<!-- 状态栏占位 -->
		<view :style="{ height: statusBarHeight + 'px' }" style="width: 100%;opacity: 0	"> 111111</view>
		<!-- 返回按钮 -->
		<view class="out"
			:style="[{height:`calc(${navBarHeight}px - ${statusBarHeight}px)`},{padding:`calc((${navBarHeight}px - ${statusBarHeight}px - ${navHie}px)/2)`}]">

			<view class="test" style="padding: 0 28rpx;" :style="testStyle">
				<view class="img" @click="handleBack" v-if="showBack">
					<view class="box " style="width:24rpx;height: 48rpx">
						<image class="" style="width:100%;height:100%" src="/static/left_arrow.png" mode=""></image>
					</view>

				</view>
				<view :class="{'isHome':ishome}">
					<text style="font-size: 32rpx;" :style="{ color: color }">{{ title }}</text>
					<text class="home_title_bottom">— 畅行全国1800市· 含港澳—</text>
				</view>

			</view>

		</view>
	</view>
</template>

<script setup>
	import {
		computed,
		ref
	} from 'vue';
	const props = defineProps({
		title: String,
		background: {
			type: String,
			default: 'rgba(255,255,255,0)'
		},
		color: {
			type: String,
			default: '#000000'
		},
		testStyle: {
			type: Object,
			default () {
				return {
					justifyContent: 'center'
				}
			}
		},
		// fontPos:{
		// 	type: String,
		// 	default: 'center'
		// },
		showBack: {
			type: Boolean,
			default: true
		},
		ishome: {
			type: Boolean,
			default: false
		}
	})
	// 顶部安全区域
	const navBarHeight = getApp().globalData.navBarHeight;
	// 状态栏
	const statusBarHeight = uni.getSystemInfoSync()?.statusBarHeight;
	const navHie = wx.getMenuButtonBoundingClientRect().height;
	const handleBack = () => {
		uni.navigateBack();
	};
	console.log('安全区域', navBarHeight);
	console.log('状态栏', statusBarHeight);
	console.log('胶囊', wx.getMenuButtonBoundingClientRect());


	const systemInfo = uni.getSystemInfoSync();
	console.log('底部安全区域:', systemInfo.screenHeight - systemInfo.safeArea.bottom);
</script>

<style>
	.navbar {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		display: flex;
		/* align-items: center; */
		flex-direction: column;
		z-index: 1000;

	}

	.out {
		/* background: pink; */

		box-sizing: border-box;
	}

	.back-btn {
		padding-left: 20rpx;
		padding-top: 48rpx;

	}



	.test {
		/* background: yellow; */
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
		position: relative;
	}

	.img {
		/* position: absolute; */
		/* left: 38rpx; */
		/* top: 0; */
		/* bottom: 0; */
		/* background: palegreen; */
		/* margin-left: 28rpx; */
		margin-right: 28rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;


	}

	.home_title_bottom {
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #555555;
		text-align: center;
		display: none;
	}
	
	.isHome .home_title_bottom{
		display: block;
		margin-top: 10rpx;
	}

	.isHome {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
</style>